/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2017-07-21 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.pbpm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.itttq.gshop.domain.po.UserScorePo;
import com.itttq.gshop.domain.to.ResultPageTo;
import com.itttq.gshop.pbpm.mapper.IUserScoreMapper;

@Service
public class UserScoreService {
	@Autowired
	private IUserScoreMapper userScoreMapper;
	
	/**
	 * 根据ID获取UserScorePo对象
	 * 
	 * @param id
	 * @return
	 * @Author 迷蝶
	 * @return UserScorePo
	 */
	public UserScorePo getUserScore(int id) {
		return userScoreMapper.findUserScoreById(id);
	}
	
	/**
	 * 根据条件获取UserScorePo对象，并返回查询的数据总数
	 * 
	 * @param userScore
	 * @Author 迷蝶
	 * @return ResultPageTo<UserScorePo>
	 */
	public ResultPageTo<UserScorePo> getUserScores(UserScorePo userScore) {
		return new ResultPageTo<UserScorePo>(userScore.getStart(), userScore.getSize(), 
				userScoreMapper.findUserScoreCount(userScore), userScoreMapper.findUserScores(userScore));
	}
	
	/**
	 * 根据条件获取UserScorePo对象，不返回查询的数据总数
	 * 
	 * @param userScore
	 * @Author 迷蝶
	 * @return List<UserScorePo>
	 */
	public List<UserScorePo> getScores(UserScorePo userScore) {
		return userScoreMapper.findUserScores(userScore);
	}
	
	/**
	 * 根据ID删除UserScorePo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 */
	public Integer delUserScore(int id) {
		return userScoreMapper.delUserScoreById(id);
	}
	
	/**
	 * 增加UserScorePo对象
	 * 
	 * @param userScore
	 * @Author 迷蝶
	 */
	public Integer addUserScore(UserScorePo userScore) {
		Integer rs = userScoreMapper.addUserScore(userScore);
		if(rs > 0) {
			// 修改用户积分值
		}
		return userScoreMapper.addUserScore(userScore);
	}
	
	/**
	 * 根据条件更新UserScorePo对象
	 * 
	 * @param userScore
	 * @Author 迷蝶
	 */
	public Integer updateUserScore(UserScorePo userScore) {
		return userScoreMapper.updateUserScore(userScore);
	}
	
}
